﻿using Wedonek.Demo.RemoteModel.User;
using Wedonek.Demo.User.Service.Interface;

namespace Wedonek.Demo.User.Service
{
    /// <summary>
    /// 用户金额TCC事务
    /// </summary>
    internal class UserMoneyTccTran : RpcClient.Interface.IRpcTranEvent<LockUserMoney>
    {
        private readonly IUserService _Servie;
        public UserMoneyTccTran(IUserService service)
        {
            this._Servie = service;
        }
        public void Commit(LockUserMoney data, string extend)
        {
            System.Console.WriteLine("用户金额提交了! ");
            this._Servie.SubmitNum(data.UserId, data.Money);
        }

        public void Rollback(LockUserMoney data, string extend)
        {
            System.Console.WriteLine("用户金额回滚了! ");
            this._Servie.RollbackNum(data.UserId, data.Money);
        }
    }
}
